﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OracleClient;

namespace Userinterface_Ver._1_
{
    public partial class frmThemKH : DevComponents.DotNetBar.Office2007Form
    {
        public frmThemKH()
        {
            InitializeComponent();
        }

        private void frmThemKH_Load(object sender, EventArgs e)
        {
           // clsConnectDatabase.con.Open();
        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtMaKH.Text !="" && txtTenKH.Text !="" && txtDiaChiKH.Text !="" && txtNamSinh.Text !="" && txtSoCMND.Text !="" && txtSoDTKH.Text !="" && txtSoTKKH.Text !="")
                {
                    string sql = "insert into KHACH_HANG values('" + txtMaKH.Text + "','" + txtTenKH.Text +
                        "','" + txtNamSinh.Text + "','" + txtSoCMND.Text + "','" + txtDiaChiKH.Text +
                        "','" + txtSoTKKH.Text + "','" + txtSoDTKH.Text + "')";
                    OracleCommand com = new OracleCommand(sql, clsConnectDatabase.con);
                    com.ExecuteNonQuery();
                    MessageBox.Show("Thêm khách hàng thành công!!!!!!!", "THÔNG BÁO");
                    txtMaKH.Text = "";
                    txtTenKH.Text = "";
                    txtNamSinh.Text = "";
                    txtDiaChiKH.Text = "";
                    txtSoCMND.Text = "";
                    txtSoDTKH.Text = "";
                    txtSoTKKH.Text = "";
                }
                else
                {
                    MessageBox.Show("KHÔNG ĐỦ DỮ LIỆU!!!!","THÔNG BÁO");
                }

            }
            catch (OracleException ex)
            {
                MessageBox.Show(ex.Message,"lỗi");
            }
        }

        private void btnLamLai_Click(object sender, EventArgs e)
        {
            txtMaKH.Text = "";
            txtTenKH.Text = "";
            txtNamSinh.Text = "";
            txtDiaChiKH.Text = "";
            txtSoCMND.Text = "";
            txtSoDTKH.Text = "";
            txtSoTKKH.Text = "";
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
            frmKhachHang kh = new frmKhachHang();
            kh.Show();
        }
    }
}
